//*************************************************************************************
// Sphere.java              Author: sanjin
//
// 构造方法，计算并返回球的体积和表面积。
//*************************************************************************************
public class Sphere{
 public double a, b;
 public Sphere(double n)
{
 a = n + 0;// n为球体的直径
}
 //计算表面积
 public double SuperficialArea()
{
 a = 4 * Math.pow((a / 2),2) * Math.PI;
 return a;
}
 //计算体积
 public double Volume()
{
 b = (4 / 3) * Math.pow((a / 2),3) * Math.PI;
 return b;
}
 public String toString()
{
 String result = "superficial area: "+ a + "\nvolume: "+b ;
 return result;
}
}
